<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机密码生成器</title>
    <link rel="stylesheet" href="./common.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
    <style>
        /* 基础样式和变量 */
        :root {
            --primary-color: #4a6fa5;
            --secondary-color: #6c8ebd;
            --background-color: #f5f7fa;
            --card-background: #ffffff;
            --text-color: #333333;
            --border-color: #e0e0e0;
            --error-color: #e74c3c;
            --success-color: #2ecc71;
            --shadow-color: rgba(0, 0, 0, 0.1);
            --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            --tip-background: #e3f2fd;
        }

        /* 暗黑模式变量 */
        [data-theme="dark"] {
            --primary-color: #5b8ad6;
            --secondary-color: #7fa3d7;
            --background-color: #1a1a2e;
            --card-background: #222438;
            --text-color: #e0e0e0;
            --border-color: #444444;
            --shadow-color: rgba(0, 0, 0, 0.3);
            --tip-background: #1a2a3a;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: var(--font-family);
            background-color: var(--background-color);
            color: var(--text-color);
            line-height: 1.6;
            transition: background-color 0.3s, color 0.3s;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* 头部样式 */
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border-color);
        }

        header h1 {
            font-size: 2rem;
            color: var(--primary-color);
        }

        /* 头部控件区域 */
        .header-controls {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        /* 分享按钮 */
        .share-button {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 2px 6px;
            background-color: var(--secondary-color);
            color: white;
            border-radius: 15px;
            cursor: pointer;
            font-size: 14px;
            transition: background-color 0.3s, transform 0.1s;
        }

        .share-button:hover {
            background-color: var(--primary-color);
        }

        .share-button:active {
            transform: scale(0.98);
        }

        .share-button i {
            font-size: 16px;
        }

        /* 主题切换开关 */
        .theme-toggle {
            position: relative;
        }

        .theme-switch {
            opacity: 0;
            position: absolute;
        }

        .theme-switch-label {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            width: 50px;
            height: 26px;
            background-color: #83d8ff;
            border-radius: 100px;
            position: relative;
            transition: background-color 0.3s;
            padding: 0 5px;
        }

        .theme-switch:checked + .theme-switch-label {
            background-color: #4a4e69;
        }

        .theme-switch-label .fa-sun {
            color: #f39c12;
        }

        .theme-switch-label .fa-moon {
            color: #f1c40f;
        }

        .theme-switch-label .slider {
            position: absolute;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            transition: 0.3s;
            background-color: white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            left: 2px;
        }

        .theme-switch:checked + .theme-switch-label .slider {
            transform: translateX(24px);
        }

        /* 隐私提示框样式 */
        .privacy-notice {
            margin-bottom: 20px;
            animation: fadeIn 0.5s ease-in-out;
        }

        .privacy-notice-content {
            display: flex;
            align-items: center;
            background-color: var(--tip-background);
            border-left: 4px solid #2196f3;
            padding: 15px;
            border-radius: 4px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            position: relative;
        }

        .privacy-notice-content i.fa-shield-alt {
            font-size: 20px;
            color: #2196f3;
            margin-right: 15px;
        }

        .privacy-notice-content p {
            flex: 1;
            margin: 0;
            font-size: 14px;
            color: var(--text-color);
        }

        .close-notice {
            background: none;
            border: none;
            color: #90a4ae;
            cursor: pointer;
            font-size: 16px;
            padding: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color 0.2s;
        }

        .close-notice:hover {
            color: #546e7a;
            background: none;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* 主内容区域 */
        main {
            flex: 1;
            display: flex;
            gap: 20px;
        }

        .main-content {
            flex: 2;
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .sidebar {
            flex: 1;
            max-width: 300px;
        }

        /* 侧边栏样式 */
        .sidebar-section {
            background-color: var(--card-background);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            padding: 20px;
            margin-bottom: 20px;
            transition: background-color 0.3s, box-shadow 0.3s;
        }

        .sidebar-section h3 {
            margin-bottom: 15px;
            color: var(--primary-color);
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .tool-links {
            list-style: none;
        }

        .tool-links li {
            margin-bottom: 10px;
        }

        .tool-links a {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--text-color);
            text-decoration: none;
            padding: 8px 12px;
            border-radius: 4px;
            transition: background-color 0.3s, color 0.3s;
        }

        .tool-links a:hover {
            background-color: var(--tip-background);
            color: var(--primary-color);
        }

        .ad-placeholder {
            background: linear-gradient(45deg, #f0f0f0, #e0e0e0);
            border: 2px dashed #ccc;
            border-radius: 8px;
            padding: 40px 20px;
            text-align: center;
            color: #999;
            font-style: italic;
        }

        [data-theme="dark"] .ad-placeholder {
            background: linear-gradient(45deg, #333, #444);
            border-color: #555;
            color: #777;
        }

        .config-panel {
            background-color: var(--card-background);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            padding: 20px;
        }

        .config-panel h2 {
            margin-bottom: 20px;
            color: var(--primary-color);
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 1.2rem;
        }

        /* 字符选择区域 */
        .character-options {
            margin-bottom: 20px;
        }

        .character-options h3 {
            margin-bottom: 15px;
            color: var(--text-color);
            font-size: 1rem;
        }

        .character-checkboxes {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 15px;
        }
        
        @media (max-width: 768px) {
            .character-checkboxes {
                grid-template-columns: repeat(2, 1fr);
            }
        }
        
        @media (max-width: 480px) {
            .character-checkboxes {
                grid-template-columns: 1fr;
            }
        }

        .checkbox-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px;
            background-color: var(--tip-background);
            border-radius: 4px;
            transition: background-color 0.3s;
        }

        .checkbox-item:hover {
            background-color: var(--border-color);
        }

        .checkbox-item input[type="checkbox"] {
            width: 18px;
            height: 18px;
            accent-color: var(--primary-color);
        }

        .checkbox-item label {
            cursor: pointer;
            font-weight: 500;
        }

        .checkbox-item .char-preview {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            background-color: var(--card-background);
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 12px;
            color: var(--text-color);
            border: 1px solid var(--border-color);
        }

        /* 配置选项区域 */
        .config-options {
            display: flex;
            flex-direction: column;
            gap: 20px;
            margin-bottom: 20px;
        }

        .config-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .config-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .config-group label {
            font-weight: 500;
            color: var(--text-color);
        }

        .config-group input {
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: var(--card-background);
            color: var(--text-color);
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .config-group input:focus {
            outline: none;
            border-color: var(--primary-color);
        }

        /* 数字输入框样式优化 */
        .config-group input[type="number"] {
                max-width: 130px;
            }

        .config-group textarea {
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: var(--card-background);
            color: var(--text-color);
            font-size: 14px;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            resize: vertical;
            min-height: 80px;
            transition: border-color 0.3s;
        }

        .config-group textarea:focus {
            outline: none;
            border-color: var(--primary-color);
        }

        .length-range {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .length-range input {
            flex: 1;
            width: auto;
        }

        .length-range span {
            color: var(--text-color);
            font-weight: bold;
        }

        /* 生成按钮 */
        .generate-section {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            margin: 20px 0;
        }

        .generate-btn {
            padding: 15px 30px;
            border: none;
            border-radius: 4px;
            background-color: var(--primary-color);
            color: white;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 10px;
            transition: background-color 0.3s, transform 0.1s;
        }

        .generate-btn:hover {
            background-color: var(--secondary-color);
        }

        .generate-btn:active {
            transform: scale(0.98);
        }

        /* 结果显示区域 */
        .result-panel {
            background-color: var(--card-background);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            padding: 20px;
        }

        .result-panel h2 {
            margin-bottom: 15px;
            color: var(--primary-color);
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 1.2rem;
        }

        .result-textarea {
            width: 100%;
            height: 200px;
            padding: 15px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: var(--tip-background);
            color: var(--text-color);
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 14px;
            line-height: 1.5;
            resize: vertical;
            transition: border-color 0.3s;
        }

        .result-textarea:focus {
            outline: none;
            border-color: var(--primary-color);
        }

        /* 复制按钮 */
        .copy-btn {
            padding: 15px 30px;
            border: none;
            border-radius: 4px;
            background-color: var(--success-color);
            color: white;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 10px;
            transition: background-color 0.3s, transform 0.1s;
        }

        .copy-btn:hover {
            background-color: #27ae60;
        }

        .copy-btn:active {
            transform: scale(0.98);
        }

        /* 通知样式 */
        .notification {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: var(--success-color);
            color: white;
            padding: 10px 20px;
            border-radius: 4px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            transform: translateY(100px);
            opacity: 0;
            transition: transform 0.3s, opacity 0.3s;
        }

        .notification.show {
            transform: translateY(0);
            opacity: 1;
        }

        .notification.error {
            background-color: var(--error-color);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .privacy-notice-content {
                flex-direction: column;
                text-align: center;
                padding: 15px 10px;
            }
            
            .privacy-notice-content i.fa-shield-alt {
                margin-right: 0;
                margin-bottom: 10px;
            }
            
            .close-notice {
                position: absolute;
                top: 5px;
                right: 5px;
            }

            header {
                flex-direction: column;
                gap: 15px;
                text-align: center;
            }

            .character-checkboxes {
                grid-template-columns: 1fr;
            }

            .config-row {
                grid-template-columns: 1fr;
            }
        }
    </style>
    <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
</head>
<body>
    <header>
        <div class="header-container">
            <div class="header-left">
                <div class="logo">
                    <span><a href="https://geekdaxue.co/" target="_blank"><img src="https://geekdaxue.co/static/images/logo_platypus.png" height="30px"></a></span>
                </div>
                <nav class="main-navigation">
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            JSON工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../json/index.html">JSON 格式化</a>
                            <a href="../json/parser.html">JSON 格式校验</a>
                            <a href="../json/excel.html">JSON 转 Excel/CSV</a>
                            <a href="../json/jsonxml.html">JSON 与 XML 转换</a>
                            <a href="../json/editor.html">JSON 编辑器</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            编码转换 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../coding/base64.html">Base64 编码</a>
                            <a href="../coding/urlencoding.html">URL 编码</a>
                            <a href="../coding/md5.html">MD5 加密</a>
                            <a href="../coding/unicode.html">Unicode 转换</a>
                            <a href="../coding/hex_convert.html">进制转换</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            文本工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../txt/diff.html">文本对比</a>
                            <a href="../txt/replace.html">文本替换</a>
                            <a href="../txt/remove.html">空白行移除</a>
                            <a href="../txt/cn_trans.html">繁简体转换</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            图片工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../img/2svg.html">图片转 SVG</a>
                            <a href="../img/qr_code.html">二维码生成</a>
                            <a href="../img/barcode.html">条形码生成</a>
                        </div>
                    </div>
                </nav>
            </div>
            <div class="header-controls">
                <div class="theme-toggle">
                    <input type="checkbox" id="theme-switch" class="theme-switch">
                    <label for="theme-switch" class="theme-switch-label">
                        <i class="fas fa-sun"></i>
                        <i class="fas fa-moon"></i>
                        <span class="slider"></span>
                    </label>
                </div>
                <div class="share-button" id="share-button" title="分享给朋友">
                    <i class="fas fa-share-alt"></i>
                    <span>分享</span>
                </div>
            </div>
        </div>
    </header>
    <div class="container">
        <div id="privacy-notice" class="privacy-notice">
            <div class="privacy-notice-content">
                <i class="fas fa-shield-alt"></i>
                <p>安全提示：您的密码仅在本地浏览器中生成，不会上传到服务器，请放心使用！</p>
                <button id="close-notice" class="close-notice" title="关闭提示">
                    <i class="fas fa-times"></i>
                </button>
            </div>
        </div>
        
        <main>
            <div class="main-content">
                <div class="config-panel">
                    <h2><i class="fas fa-cog"></i> 密码配置</h2>
                    
                    <div class="character-options">
                        <h3>使用字符</h3>
                        <div class="character-checkboxes">
                            <div class="checkbox-item">
                                <input type="checkbox" id="use-numbers" checked>
                                <label for="use-numbers">数字</label>
                                <span class="char-preview">0-9</span>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="use-lowercase" checked>
                                <label for="use-lowercase">小写字母</label>
                                <span class="char-preview">a-z</span>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="use-uppercase" checked>
                                <label for="use-uppercase">大写字母</label>
                                <span class="char-preview">A-Z</span>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="use-symbols">
                                <label for="use-symbols">特殊字符</label>
                                <span class="char-preview">!@#$%^&*</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="config-options">
                        <div class="config-row">
                            <div class="config-group">
                                <label for="password-count">生成数量</label>
                                <input type="number" id="password-count" value="1" min="1" max="100">
                            </div>
                            <div class="config-group">
                                <label>密码长度</label>
                                <div class="length-range">
                                    <input type="number" id="password-min-length" value="15" min="1" placeholder="最小值">
                                    <span>-</span>
                                    <input type="number" id="password-max-length" min="1" placeholder="最大值（可选）">
                                </div>
                            </div>
                        </div>
                        <div class="config-row">
                            <div class="config-group">
                                <label for="exclude-chars">排除字符</label>
                                <input type="text" id="exclude-chars" placeholder="0oO1iIlLq9g" value="0oO1iIlLq9g">
                            </div>
                            <div class="config-group">
                                <label for="include-chars">包含字符</label>
                                <input type="text" id="include-chars" placeholder="如果设置，将只使用这些字符生成密码">
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="generate-section">
                    <button id="generate-btn" class="generate-btn">
                        <i class="fas fa-key"></i> 生成密码
                    </button>
                    <button id="copy-btn" class="copy-btn" style="display: none;">
                        <i class="fas fa-copy"></i> 复制密码
                    </button>
                </div>
                
                <div class="result-panel">
                    <h2><i class="fas fa-lock"></i> 密码</h2>
                    <textarea id="result-textarea" class="result-textarea" readonly placeholder="点击上方按钮生成密码..."></textarea>
                </div>
            </div>
            
            <div class="sidebar">
                <div class="sidebar-section">
                    <div class="wwads-cn wwads-vertical" data-id="321" style="max-width:200px"></div>
                </div>

                <div class="sidebar-section">
                    <h3><i class="fas fa-info-circle"></i> 使用说明</h3>
                    <p style="font-size: 14px; line-height: 1.6; color: var(--text-color);">
                        1. 选择要使用的字符类型<br>
                        2. 设置生成数量和密码长度<br>
                        3. 可选择排除容易混淆的字符<br>
                        4. 如需自定义字符集，可设置包含字符<br>
                        5. 点击生成密码按钮获取随机密码<br>
                        6. 点击复制按钮将密码复制到剪贴板
                    </p>
                </div>
                <div class="sidebar-section">
                    <h3><i class="fas fa-tools"></i> 其他工具</h3>
                    <ul class="tool-links">
                        <li><a href="../json/index.html"><i class="fas fa-code"></i> JSON 工具</a></li>
                        <li><a href="uuid.html"><i class="fas fa-key"></i> UUID 生成器</a></li>
                        <li><a href="base64.html"><i class="fas fa-lock"></i> Base64 编解码</a></li>
                        <li><a href="md5.html"><i class="fas fa-fingerprint"></i> MD5 加密</a></li>
                        <li><a href="timestamp.html"><i class="fas fa-clock"></i> 时间戳转换</a></li>
                        <li><a href="urlencoding.html"><i class="fas fa-link"></i> URL 编解码</a></li>
                        <li><a href="unicode.html"><i class="fas fa-globe"></i> Unicode 转换</a></li>
                        <li><a href="qr_code.html"><i class="fas fa-qrcode"></i> 二维码生成</a></li>
                        <li><a href="guid.html"><i class="fas fa-hashtag"></i> GUID 生成器</a></li>
                        <li><a href="regex.html"><i class="fas fa-search"></i> 正则表达式测试</a></li>
                    </ul>
                </div>
            </div>
        </main>
    </div>
    <footer>
            <div class="footer-container">
                <div class="footer-main">
                    <div class="footer-section about-us">
                        <h3>关于我们</h3>
                        <p>我们提供一系列高效、便捷的在线工具，帮助开发者、非技术人员提高工作效率，解决日常开发中遇到的各种问题。</p>
                        <p>Build With <i class="fa-solid fa-heart" style="color: red;"></i> For SF.</p>
                    </div>
                    <div class="footer-section links">
                        <h3>工具导航</h3>
                        <div class="links-columns">
                            <ul>
                                <li><a href="../json/index.html">JSON 工具</a></li>
                                <li><a href="../img/index.html">图片处理</a></li>
                                <li><a href="#">开发工具</a></li>
                            </ul>
                            <ul>
                                <li><a href="../coding/index.html">编码转换</a></li>
                                <li><a href="../txt/index.html">文本工具</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="footer-section contact">
                        <h3>联系我们</h3>
                        <div class="social-icons">
                            <a href="#" title="GitHub"><i class="fab fa-github"></i></a>
                            <a href="#" title="Twitter"><i class="fab fa-twitter"></i></a>
                            <a href="#" title="WeChat"><i class="fab fa-weixin"></i></a>
                            <a href="mailto:example@example.com" title="Email"><i class="fas fa-envelope"></i></a>
                        </div>
                        <p>如有问题或建议，请随时联系我们</p>
                    </div>
                </div>
                <div class="footer-bottom">
                    <div class="footer-legal">
                        <a href="#">使用条款</a>
                        <a href="#">隐私政策</a>
                    </div>
                </div>
            </div>
        </footer>
    
    <div id="notification" class="notification"></div>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const themeSwitch = document.getElementById('theme-switch');
            const privacyNotice = document.getElementById('privacy-notice');
            const closeNoticeBtn = document.getElementById('close-notice');
            const shareButton = document.getElementById('share-button');
            const generateBtn = document.getElementById('generate-btn');
            const copyBtn = document.getElementById('copy-btn');
            const notification = document.getElementById('notification');
            
            const useNumbers = document.getElementById('use-numbers');
            const useLowercase = document.getElementById('use-lowercase');
            const useUppercase = document.getElementById('use-uppercase');
            const useSymbols = document.getElementById('use-symbols');
            
            const passwordCount = document.getElementById('password-count');
            const passwordMinLength = document.getElementById('password-min-length');
            const passwordMaxLength = document.getElementById('password-max-length');
            const excludeChars = document.getElementById('exclude-chars');
            const includeChars = document.getElementById('include-chars');
            const resultTextarea = document.getElementById('result-textarea');
            
            // 字符集定义
            const charSets = {
                numbers: '0123456789',
                lowercase: 'abcdefghijklmnopqrstuvwxyz',
                uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                symbols: '!@#$%^&*()_+-=[]{}|;:,.<>?'
            };
            
            // 检查本地存储中的主题设置
            if (localStorage.getItem('theme') === 'dark') {
                document.documentElement.setAttribute('data-theme', 'dark');
                themeSwitch.checked = true;
            }
            
            // 主题切换功能
            themeSwitch.addEventListener('change', function() {
                if (this.checked) {
                    document.documentElement.setAttribute('data-theme', 'dark');
                    localStorage.setItem('theme', 'dark');
                } else {
                    document.documentElement.removeAttribute('data-theme');
                    localStorage.setItem('theme', 'light');
                }
            });
            
            // 隐私提示框关闭功能
            closeNoticeBtn.addEventListener('click', function() {
                privacyNotice.style.display = 'none';
                localStorage.setItem('privacyNoticeClosed', 'true');
            });
            
            // 检查是否需要显示隐私提示
            if (localStorage.getItem('privacyNoticeClosed') === 'true') {
                privacyNotice.style.display = 'none';
            }
            
            // 分享功能
            shareButton.addEventListener('click', function() {
                const url = window.location.href;
                navigator.clipboard.writeText(url).then(() => {
                    showNotification('已复制网址，赶快让更多的小伙伴知道我吧！');
                }).catch(() => {
                    showNotification('复制失败，请手动复制网址', true);
                });
            });
            
            // 显示通知
            function showNotification(message, isError = false) {
                notification.textContent = message;
                notification.className = 'notification show' + (isError ? ' error' : '');
                setTimeout(() => {
                    notification.classList.remove('show');
                }, 3000);
            }
            
            // 生成随机密码
            function generatePassword(length, charset) {
                let password = '';
                for (let i = 0; i < length; i++) {
                    const randomIndex = Math.floor(Math.random() * charset.length);
                    password += charset[randomIndex];
                }
                return password;
            }
            
            // 获取可用字符集
            function getCharset() {
                // 如果设置了包含字符，只使用包含字符
                const includeCharsValue = includeChars.value.trim();
                if (includeCharsValue) {
                    return includeCharsValue;
                }
                
                let charset = '';
                
                if (useNumbers.checked) charset += charSets.numbers;
                if (useLowercase.checked) charset += charSets.lowercase;
                if (useUppercase.checked) charset += charSets.uppercase;
                if (useSymbols.checked) charset += charSets.symbols;
                
                // 排除指定字符
                const excludeCharsValue = excludeChars.value.trim();
                if (excludeCharsValue) {
                    for (const char of excludeCharsValue) {
                        charset = charset.replace(new RegExp(char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), '');
                    }
                }
                
                return charset;
            }
            
            // 生成密码按钮事件
            generateBtn.addEventListener('click', function() {
                const charset = getCharset();
                
                if (!charset) {
                    showNotification('请至少选择一种字符类型或设置包含字符！', true);
                    return;
                }
                
                const count = parseInt(passwordCount.value) || 1;
                const minLength = parseInt(passwordMinLength.value) || 15;
                const maxLengthInput = passwordMaxLength.value;
                const maxLength = maxLengthInput ? parseInt(maxLengthInput) : minLength;
                
                if (count < 1 || count > 100) {
                    showNotification('生成数量必须在1-100之间！', true);
                    return;
                }
                
                if (minLength < 1) {
                    showNotification('最小密码长度必须大于0！', true);
                    return;
                }
                
                if (maxLengthInput && maxLength < minLength) {
                    showNotification('最大长度不能小于最小长度！', true);
                    return;
                }
                
                const passwords = [];
                for (let i = 0; i < count; i++) {
                    // 随机生成长度（在最小值和最大值之间）
                    const length = minLength + Math.floor(Math.random() * (maxLength - minLength + 1));
                    passwords.push(generatePassword(length, charset));
                }
                
                resultTextarea.value = passwords.join('\n');
                copyBtn.style.display = 'inline-flex';
                showNotification(`成功生成${count}个密码！`);
            });
            
            // 复制密码按钮事件
            copyBtn.addEventListener('click', function() {
                if (!resultTextarea.value.trim()) {
                    showNotification('没有可复制的密码！', true);
                    return;
                }
                
                navigator.clipboard.writeText(resultTextarea.value).then(() => {
                    showNotification('密码已复制到剪贴板！');
                }).catch(() => {
                    showNotification('复制失败，请手动复制！', true);
                });
            });
            
            // 键盘快捷键
            document.addEventListener('keydown', function(e) {
                if (e.ctrlKey || e.metaKey) {
                    switch(e.key) {
                        case 'Enter':
                            e.preventDefault();
                            generateBtn.click();
                            break;
                        case 'c':
                            if (e.shiftKey && resultTextarea.value.trim()) {
                                e.preventDefault();
                                copyBtn.click();
                            }
                            break;
                    }
                }
            });
        });
    </script>
</body>
</html>